<!doctype html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>工程师登录</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
</head>
<body class="login-bg">

<div class="login layui-anim layui-anim-up">
    <div class="message">管理员登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form" id="form">
        <input name="name" placeholder="登录名" type="text" lay-verify="required" class="layui-input" id="name">
        <hr class="hr15">
        <input name="yzm" lay-verify="required" placeholder="验证码" type="layui-input" class="layui-input" id="yzm">
        <hr class="hr15">
        <!--滑块验证-->
        <input id="slider"/>

        <hr class="hr20">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20">
        <input value="注册"  lay-filter="zhuce" style="width:100%;" id="zhuce" type="button">
    </form>
</div>

<script>
    //一般直接写在一个js文件中
    layui.config({
        base: 'dist/sliderVerify/'
    }).use(['sliderVerify', 'jquery', 'form'], function () {
        var sliderVerify = layui.sliderVerify,
            form = layui.form;
        var slider = sliderVerify.render({
            elem: '#slider'
        })
        //监听提交
        form.on('submit(formDemo)', function (data) {
            if (slider.isOk()) {//用于表单验证是否已经滑动成功
                layer.msg(JSON.stringify(data.field));
            } else {
                layer.msg("请先通过滑块验证");
            }
            return false;
        });
    })
</script>
<script>
    $(function () {
        layui.use(['form', 'jquery'], function () {
            var form = layui.form;
            $ = layui.jquery;

            $("#zhuce").click(function () {
                location.href="repairman_add.html";
            })

            form.on('submit(login)', function (data) {
                var name = $("#name").val();
                var yzm = $("#yzm").val();
                $.get("repairLogin", {name: name, yzm: yzm}, function (d) {
                    if (d.code == 0) {    /*data.code==0*/
                        window.sessionStorage.setItem("user", JSON.stringify(d.data));
                        location.href = 'repairman_index.html';
                        return false;
                    }
                    layer.msg("登陆失败",{icon:5});
                })
                return false;
            });
        })
    })
</script>
</body>
</html>
